<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>物资明细</title>
<style type="text/css">
.info_dialog .content_container .content_table tr td input[type="checkbox"] {
	width: auto;
}
</style>
</head>
<body>
	<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">物资明细管理</div>
		</div>
	</div>

	<div class="new-form">
		<div>
			<form id="ff" method="post">
				<table cellpadding="5" style="margin: auto;">
					<tr>
						<td style="width: 80px;">类别：</td>
						<td>
							<div>
							<span style="position: relative;top: 2px;"><input type="checkbox" name="type" value="1" /></span>
							<span>增加</span>
							<span style="position: relative;top: 2px;display:inline-block;margin-left:5px;"><input type="checkbox" name="type" value="2" /></span>
							<span>减少</span>
							</div>
						</td>
					</tr>
					<tr>
						<td style="width: 80px;">数量：</td>
						<td>
							<input class="easyui-textbox" data-options="validType:'number'" id="difference" name="difference"
								style="width: 100%" />
						</td>
					</tr>
				</table>
			</form>
			<div style="text-align: center;" id="div1">
				<a href="#" class="d-btn btn-blue" onclick="savePro()">保存</a>
			</div>
		</div>
	</div>
</body>
<script th:inline="javascript">
	var goods = [[${goods}]];
	var currentPro={};
	
	$("input[name='type']:checkbox").click(function () {
        var flag = $(this).is(':checked');
        if (flag) {
            $(this).siblings("input").attr("checked", false);
        }
    });
	
	function savePro() {
		var type = $('input:checkbox[name="type"]:checked').val();
		currentPro.type = type;
		currentPro.difference = $("#difference").textbox('getValue');
		currentPro.goodsid = goods.id;
		$.ajax({
			type : 'POST',
			url : "../goodsCurrentSave.do",
			data : JSON.stringify(currentPro),
			contentType : "application/json",
			success : function(data) {
				if (data.success) {
					$.messager.alert('保存物资明细', '保存物资明细成功', 'success');
				} else {
					$.messager.alert('保存物资明细', '保存物资明细失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(), month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(), hour = date.getHours(), min = date.getMinutes(), sec = date
				.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
	$.extend($.fn.textbox.defaults.rules, {
		number : {//value值为文本框中的值
			validator : function(value) {
				var reg = /^\d+(\.\d+)?$/;
				return reg.test(value);
			},
			message : "请输入的数字"
		}
	});
</script>
</html>